package com.example.littleken.dialogtext;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;

public class ProgressBarActivity extends AppCompatActivity {
    private Button btn_begin;
    private ProgressBar firstBar;
    private ProgressBar secondBar;
    private int i=0;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_progress_bar);
        initView();
        btn_begin.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(i == 0){
                    firstBar.setVisibility(View.VISIBLE);
                    secondBar.setVisibility(View.VISIBLE);
                    firstBar.setMax(150);
                }else if(i < firstBar.getMax()){
                    firstBar.setProgress(i);
                    firstBar.setSecondaryProgress(i+10);
                }else{
                    firstBar.setVisibility(View.GONE);
                    secondBar.setVisibility(View.GONE);
                }
                i += 10;
            }
        });
    }

    private void initView() {
        btn_begin = (Button) findViewById(R.id.btn_begin);
        firstBar = (ProgressBar) findViewById(R.id.firstBar);
        secondBar = (ProgressBar) findViewById(R.id.secondBar);

    }
}
